// 设置 token
$(document).ajaxSend((e, xhr, opt) => {
  let userToken = localStorage.getItem('user_token_key')
  xhr.setRequestHeader('user_token_head', userToken)
})

// 查询用户信息
function getUserInfo(url) {
  $.ajax({
    url,
    type: 'get',
    success(result) {
      const { data } = result
      if (result.code === RESPONSE_CODE_STATUS.success && data) {
        // 有值
        $('.left .card h3').text(data.userName)
        $('.left .card a').attr('href', data.githubUrl)
      } else {
        // ...
      }
    }, error(e) {
      console.log('error', e);
      
    }
  })
}

// 登出
function logout() {
  localStorage.removeItem('user_token_key')
  location.href = '/blog_login.html'
}